package com.example.dao;

import com.example.domain.RewardPunish;
import com.example.domain.Salary;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * @author luo
 */
@Mapper
public interface SalaryDao {
    /**
     * 查询所有员工薪资
     * @return
     */
    @Select("select * from salary")
    public List<Salary> selectSalary();

    /**
     * 查询单个员工薪资
     * @return
     */
    @Select("select * from salary where id=#{id}")
    public Salary selectSalaryById(Integer id);

    /**
     * 模糊查询
     * @param name
     * @return
     */
//    @Select("select * from salary where name like CONCAT('%',#{name},'%');")
    public List<Salary> selectSalaryByName(String name);

    /**
     * 添加员工薪资信息
     * @param salary
     * @return
     */
    @Insert("insert into salary (name, wages, allday,train,overtime,absent,insurance,sum) values (#{name},#{wages},#{allday},#{train},#{overtime},#{absent},#{insurance},#{sum})")
    public int addSalary(Salary salary);

    /**
     * 更新员工薪资信息
     *
     * @param salary
     * @return
     */
    @Update("update salary set name = #{name},wages=#{wages},allday=#{allday},train=#{train},overtime=#{overtime},absent=#{absent},insurance=#{insurance},sum=#{sum} where id=#{id};")
    public int updateSalary(Salary salary);

    /**
     * 根据id删除
     * @param id
     * @return
     */
    @Delete("delete from salary where id=#{id};")
    public int deleteSalary(Integer id);
}
